package com.meida.module.bus.provider.handler;

import com.meida.common.base.entity.EntityMap;
import com.meida.common.mybatis.interceptor.PageInterceptor;
import com.meida.common.mybatis.model.PageParams;
import com.meida.common.mybatis.query.CriteriaQuery;
import com.meida.module.bus.client.entity.BusScholartyrant;
import com.meida.module.user.client.entity.AppSchool;
import com.meida.module.user.client.entity.AppUser;
import org.springframework.stereotype.Component;

/**
 * 后台App用户列表
 */
@Component
public class AppUserPageListHandler implements PageInterceptor<AppUser> {


    @Override
    public void prepare(CriteriaQuery<AppUser> cq, PageParams pageParams, EntityMap params) {
        cq.select(BusScholartyrant.class, "roleTagName");
        cq.select(AppSchool.class, "schoolName");
        cq.like(BusScholartyrant.class, "roleTagName");
        cq.ge("DATE_FORMAT(user.birthday,'%Y-%m-%d')", cq.getParams("birthdayBeginDate"));
        cq.le("DATE_FORMAT(user.birthday,'%Y-%m-%d')", cq.getParams("birthdayEndDate"));
        cq.createJoin(BusScholartyrant.class).setMainField("userId").setJoinField("scholartyrantId");
        cq.createJoin(AppSchool.class).setMainField("schoolId").setJoinField("schoolId");
    }


}
